package com.example.first.bean;

public class User {

    //依赖项
    private String name;
    private int age;

    //注入依赖项的构造方法
    public User(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public User() {
        this.name = name;
        this.age = age;
    }

    public String getName(){
        return name;
    }

    public void setName(String name){//使用setter必须要有set方法
        this.name = name;
    }

    public Integer getAge(){
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }
    public String toString() {
        System.out.println("User的toString()方法执行了");
        System.out.println("User{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}');
        return null;
    }
}
